package cn.itsource.org.controller;

import cn.itsource.basic.util.AjaxResult;
import cn.itsource.org.domain.Employee;
import cn.itsource.org.domain.User;
import cn.itsource.org.service.IEmployeeService;
import cn.itsource.org.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {

    /**
     * 业务需要写service层,调用对应的service
     */
    @Autowired
    private IEmployeeService employeeService;
    @Autowired
    private IUserService userService;

    /**
     *     var loginParams = { username: this.ruleForm2.account, password: this.ruleForm2.checkPass };
     *
     *     //发送请求
     *     this.$http.post("/system/login",loginParams).then(data => {
     *     post 对象 @RequestBody 对象
     *
     */
    @PostMapping("/system/login")
    public AjaxResult login(@RequestBody Employee employee){
        //调用业务层
        return employeeService.login(employee);

    }


    @PostMapping("/user/login")
    public AjaxResult userLogin(@RequestBody User user){
        //调用业务层
        return userService.userLogin(user);

    }


}
